package com.sg.business.permission.dataset;

import java.util.List;

import com.mobnut.db.model.DataSet;
import com.mobnut.db.model.PrimaryObject;
import com.sg.business.model.DummyModel;
import com.sg.business.model.IModelConstants;
import com.sg.business.model.Organization;
import com.sg.business.permission.model.PermissionVisitorFactory;
import com.sg.business.resource.nls.Messages;

public class OrganizationVisitorDataSet extends VisitorDataSet {

	public OrganizationVisitorDataSet() {
		super(IModelConstants.DB, IModelConstants.C_ORGANIZATION);
	}

	@Override
	protected String getDetailCollectionKey() {
		return Organization.F_PARENT_ID;
	}
	
	@Override
	protected Object getMasterValue() {
		if(master instanceof DummyModel){
			return null;
		}
		return super.getMasterValue();
	}
	
	@Override
	public List<PrimaryObject> doQuery(DataSet ds) throws Exception {
		List<PrimaryObject> result = super.doQuery(ds);
		PrimaryObject dummyModel = getStaticVisitorDataObject(Messages.get().AllPerson,
				PermissionVisitorFactory.ALL, PermissionVisitorFactory.ALL);
		result.add(0, dummyModel);
		dummyModel = getStaticVisitorDataObject(Messages.get().Owner,
				PermissionVisitorFactory.OWNER, PermissionVisitorFactory.OWNER);
		result.add(1, dummyModel);
		return result;
	}

}
